package org.shoukaiseki.supersaiyan.db.inittable.system;

import org.shoukaiseki.inittable.domain.TableColumnInfo;
import org.shoukaiseki.inittable.domain.TableIndexInfo;
import org.shoukaiseki.inittable.domain.TableTriggerInfo;
import org.shoukaiseki.inittable.service.ITableBuildInfoService;
import org.shoukaiseki.kakaroto.SksDictUtils;
import org.shoukaiseki.kakaroto.annotation.TableBuild;
import org.shoukaiseki.supersaiyan.enums.UserThirdPartyBindingType;

import java.util.List;

import static org.shoukaiseki.inittable.utils.SksColumnCamelCaseCommon.*;
import static org.shoukaiseki.inittable.utils.TableColumnInfoBuilder.column;
import static org.shoukaiseki.inittable.utils.TableIndexInfoBuilder.index;
import static org.shoukaiseki.inittable.utils.TableIndexInfoBuilder.uniqueIndex;
import static org.shoukaiseki.inittable.utils.TableInfoUtils.*;


//@TableBuild(name = "user_third_party", comment = "绑定第三方帐号", version = 1)
public class UserThirdPartyInitTableInfo implements ITableBuildInfoService {
    @Override
    public List<TableColumnInfo> tableColumnInfoList() {
        List<TableColumnInfo> table = tableColumns(
                uniqueId("user_third_party_id"),
                column(" user_id       bigint(20) unsigned default '0'               not null comment '用户ID',"),

                column(" user_type tinyint(8) default '1' not null comment '用户类型',")
//                wb1001中: 2:seller_user用户,3:consumer_user用户
                        .description("1:sys_user用户"),

                column(" binding_type tinyint(8) default '1' NOT NULL comment '绑定类型',")
                        .description(SksDictUtils.getDictInfo(UserThirdPartyBindingType.class)),
                column("    openid   varchar(64) default ''  comment '绑定的openid',"),

                createUserId(),
                createTime(),
                updateUserId(),
                updateTime(),
                rowstamp(),

                null
        );

        return table;
    }

    @Override
    public List<TableIndexInfo> tableIndexInfoList() {
        return tableIndexs(
                index("userThirdPartyIndex1").indexColumns("userId"),
//                uniqueIndex("userThirdPartyIndex2").indexColumns("userType,bindingType"),
                uniqueIndex("userThirdPartyIndex3").indexColumns("userType,bindingType,openid"),
                null
        );
    }
}
